<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>新建资金调拨</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">

        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>调拨单号</label>
                        <div class="layui-input-block">
                            <input type="text" id="number" placeholder="请输入" readonly autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>款项摘要</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhai" id="zhai" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>调出(付款)账户</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="chuid" class="layui-input chuid" onclick="openPage('../public/choose_account.php?dom=chuid','80%','80%')">
                            <div class="choose_div" id="chuid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_account.php?dom=chuid','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>款项科目(支出)</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="chubudid" class="layui-input chubudid" onclick="openPage('../public/choose_engin_budsub_guan_gong.php?dom=chubudid','80%','80%')">
                            <div class="choose_div" id="chubudid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_engin_budsub_guan_gong.php?dom=chubudid','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>调入(收款)账户</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="ruid" class="layui-input ruid" onclick="openPage('../public/choose_account.php?dom=ruid','80%','80%')">
                            <div class="choose_div" id="ruid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_account.php?dom=ruid','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>款项科目(收入)</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="rubudid" class="layui-input rubudid" onclick="openPage('../public/choose_engin_budshou_qi.php?dom=rubudid','80%','80%')">
                            <div class="choose_div" id="rubudid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_engin_budshou_qi.php?dom=rubudid','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>转账金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="money" id="money" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">手续费(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="shoufee" id="shoufee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>交易日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="dt" id="dt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>经手人</label>
                        <div class="layui-input-block">
                            <input type="text" name="baner" id="baner" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>


            <?php include '../public/upinfo.php'?>
        </div>


    </div>
</form>
<script>
    $("#commentForm").validate({
        rules: {
            zhai: {required: true},
            money: {required: true},
            dt: {required: true},
            baner: {required: true},
        },
        messages:{
            zhai: {required: "请输入"},
            money: {required: "请输入"},
            dt: {required: "请选择"},
            baner: {required: "请输入"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_account_diao_add}).done(function(res){
            if (res.code === 2000) {
                var data = res.data;
                $("#number").val(data.number)
                $("#dt").val(data.dt)
                $("#baner").val(data.baner)



                public_upload_file_load('upload_files');
                initParseMoney();
                render_from();
            }
        });

        form.on('submit(add)', function(data){
            parseMoney(data);
            var validRes = $("#commentForm").valid();

            data.field.chuid = get_choose_val('chuid');
            formValid('chuid');
            if(data.field.chuid == undefined || !data.field.chuid){
                validRes = false;
            }

            data.field.chubudid = get_choose_val('chubudid');
            formValid('chubudid');
            if(data.field.chubudid == undefined || !data.field.chubudid){
                validRes = false;
            }

            data.field.ruid = get_choose_val('ruid');
            formValid('ruid');
            if(data.field.ruid == undefined || !data.field.ruid){
                validRes = false;
            }

            data.field.rubudid = get_choose_val('rubudid');
            formValid('rubudid');
            if(data.field.rubudid == undefined || !data.field.rubudid){
                validRes = false;
            }


            if(!validRes){return false;}

            data.field.files = public_upload_file_value('upload_files');
            facade.ajax({url: ask_account_diao_add, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });

</script>
</body>
</html>
